#include "CreditsState.h"

#include "..\Game.h"
#include "MenuState.h"

#include "..\Bitmap Font\BitmapFont.h"

#include "..\Game Objects\StationaryObject.h"

#include "..\..\SGD Wrappers\SGD_AudioManager.h"
#include "..\..\SGD Wrappers\SGD_GraphicsManager.h"
#include "..\..\SGD Wrappers\SGD_InputManager.h"


/**************************************************************/
// GetInstance
//	- store the ONLY instance in global memory
//	- return the only instance by pointer
/*static*/ CreditsState* CreditsState::GetInstance(void)
{
	static CreditsState s_Instance;

	return &s_Instance;
}

void CreditsState::Enter()
{
	papaBear = new StationaryObject();
	papaBear->SetAnimation("PapaBearIdleLeft");
	papaBear->SetPosition(SGD::Point(450, 200));
	papaBear->SetSize(SGD::Size{ 116, 126 });

	papaBear->GetAnimation()->IsLooping(true);
	papaBear->GetAnimation()->IsPlaying(true);

	qudzu = new StationaryObject();
	qudzu->SetAnimation("QudzuIdleLeft");
	qudzu->SetPosition(SGD::Point(500, 350));
	qudzu->SetSize(SGD::Size{ 116, 126 });
	qudzu->GetAnimation()->IsLooping(true);
	qudzu->GetAnimation()->IsPlaying(true);

	cheetah = new StationaryObject();
	cheetah->SetAnimation("PlayerIdleRight");
	cheetah->SetPosition(SGD::Point(500, 500));
	cheetah->SetSize(SGD::Size(60, 76));
	cheetah->GetAnimation()->IsLooping(true);
	cheetah->GetAnimation()->IsPlaying(true);

}

void CreditsState::Exit()
{
	papaBear->GetAnimation()->IsPlaying(false);
	qudzu->GetAnimation()->IsPlaying(false);
	cheetah->GetAnimation()->IsPlaying(false);

	delete papaBear;
	delete qudzu;
	delete cheetah;
}

bool CreditsState::Update(float dt)
{
	SGD::InputManager* Input = SGD::InputManager::GetInstance();

	papaBear->GetAnimation()->Update(dt);
	qudzu->GetAnimation()->Update(dt);
	cheetah->GetAnimation()->Update(dt);

	if(KEYESCAPE)
		GAME->ChangeState(MenuState::GetInstance());

	return true;
}

void CreditsState::Render()
{
	// Use game font
	papaBear->GetAnimation()->Render(papaBear->GetPosition());
	qudzu->GetAnimation()->Render(qudzu->GetPosition());
	cheetah->GetAnimation()->Render(cheetah->GetPosition());

	//g->GetEntityManager().RenderAll();

	// Align text based on window width
	float width = GAME->GetScreenWidth();

	// Display the game title
	GAME->GetBitmapFont()->Render("Credits", SGD::Point{ 100, 100 }, 0.5f, SGD::Color{ 50, 150, 150 });

	// Display menu options
	GAME->GetBitmapFont()->Render("Executive Producer", SGD::Point{ 100, 150 }, 0.5f, SGD::Color{ 210, 210, 210 });
	GAME->GetBitmapFont()->Render("John OLeske", SGD::Point{ 125, 175 }, 0.5f, SGD::Color{ 210, 210, 210 });
	GAME->GetBitmapFont()->Render("Associate Producer", SGD::Point{ 100, 225 }, 0.5f, SGD::Color{ 210, 210, 210 });
	GAME->GetBitmapFont()->Render("Sean Hathaway", SGD::Point{ 125, 250 }, 0.5f, SGD::Color{ 210, 210, 210 });
	GAME->GetBitmapFont()->Render("Shawn Paris ", SGD::Point{ 125, 275 }, 0.5f, SGD::Color{ 210, 210, 210 });

	GAME->GetBitmapFont()->Render("Programmers", SGD::Point{ 100, 325 }, 0.5f, SGD::Color{ 210, 210, 210 });
	GAME->GetBitmapFont()->Render("Cliff Baird", SGD::Point{ 125, 350 }, 0.5f, SGD::Color{ 210, 210, 210 });
	GAME->GetBitmapFont()->Render("Samuel Johnson", SGD::Point{ 125, 375 }, 0.5f, SGD::Color{ 210, 210, 210 });
	GAME->GetBitmapFont()->Render("David Desharnais", SGD::Point{ 125, 400 }, 0.5f, SGD::Color{ 210, 210, 210 });
	
	GAME->GetBitmapFont()->Render("Artist", SGD::Point{ 100, 450 }, 0.5f, SGD::Color{ 210, 210, 210 });
	GAME->GetBitmapFont()->Render("Gregory Bey", SGD::Point{ 125, 475 }, 0.5f, SGD::Color{ 210, 210, 210 });



	GAME->GetBitmapFont()->Render("Press Escape/Controller B To Exit", SGD::Point{ 125, 550 }, 0.5f, SGD::Color{ 0, 250, 250 });

}